<%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*" %>
<%
String usernameSC = (String) session.getAttribute("session_name");
String idSC = (String) session.getAttribute("id");
String typeSC = (String) session.getAttribute("type");
if(usernameSC != null && typeSC.equals("root")) {
%>
<%
String driver ="com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/projects";
String username = "ia";
String password = "123";
String [] id = null;
String [] usernames = null;
String [] type = null;
String [] status = null;
int size = 0;
try
{
	Class.forName(driver).newInstance();
	
	Connection connection = DriverManager.getConnection(url, username, password);
	
	Statement statement = connection.createStatement();
	Statement statement1 = connection.createStatement();
	String query = "select count(*) from user_log_in";
	String query1 = "select * from user_log_in";
	ResultSet rs = statement.executeQuery(query);
	if(rs.next())
	{
		size = rs.getInt(1);
	}
	id = new String[size];
	usernames = new String[size];
	type = new String[size];
	status = new String[size];
	ResultSet rs1 = statement1.executeQuery(query1);
	for(int i=0 ;rs1.next();i++)
	{
		id[i] = rs1.getString("id");
		usernames[i] = rs1.getString("username");
		type[i] = rs1.getString("type");
		status[i] = rs1.getString("status");
	}
	
	
	connection.close();
		
}catch(ClassNotFoundException cnfe)
{
		out.println("<br>Couldn't find class file" + cnfe); 
}catch(SQLException sqle)
{
		out.println("<br>SQL Exception: " + sqle);
}catch(InstantiationException ie)
{
		out.println("<br>Instant exception : " + ie);
}catch(IllegalAccessException iae)
{
		out.println("<br>Illegal access exception : " + iae);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%
String usernameS = (String) session.getAttribute("session_name");
				String idS = (String) session.getAttribute("id");
				String typeS = (String) session.getAttribute("type");
%>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<title>Graduation Projects</title>

<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<link rel="STYLESHEET" href="styles/project.css" type="text/css">
<script type="text/javascript" language="javascript" src="js/project.js"></script>
<link rel="stylesheet" href="styles/control.css" type="text/css"/>
<script type="text/javascript" language="javascript">var SIZE = <%=id.length%>;</script>
<script type="text/javascript" language="javascript" src="js/drag_drop.js"></script>

<script type="text/javascript">
function check() {
var it = new Array();
<%
	for(int i=0;i<size;i++)
	{
		out.println("it["+i+"] = document.getElementById('"+id[i]+"');");
	}
%>
for(var i=0;i<it.length;i++)
{
	if(it[i] != null && it[i].parentNode.id == "DragContainer4")
	{
		document.getElementById("in"+i).value = "accepted";
	}
	else if(it[i] != null && it[i].parentNode.id == "DragContainer5")
	{
		document.getElementById("in"+i).value = "pend";
	}
	else if(it[i] != null && it[i].parentNode.id == "DragContainer6")
	{
		document.getElementById("in"+i).value = "drop";
	}
	
}
return true;
}
var count = 0;
function refreshPage()
{
	if (location.href.indexOf('reload') == -1)
		location.replace(location.href + '?reload');
}
	</script>
</head>

<body>

<div id="container">

	<!-- Start of Page Header -->

	<div id="header_container">
	<div id="page_header">

		<div id="header_menu">

			<jsp:include page="links.jsp"/>

		</div>

		<div id="header_welcome">
			<div id="welcome_text"><object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj8" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="680" height="120">	<param name="movie" value="mainlogo.swf"><param name="quality" value="High"><embed src="mainlogo.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj8" width="680" height="89" quality="High"></object>
			</div>

		</div>

	</div>
	</div>

	<!-- End of Page Header -->


	<!-- Start of Left Sidebar -->

	<div id="left_sidebar">

		<!-- Start of User Login -->

		<div class="box_container">
		<div id="userlogin">

			<%

				if(usernameS != null) {
					%>
					<center><jsp:include page="detail.jsp"/></center>
					<%
				} else {
					%>
					<center><jsp:include page="login.jsp"/></center>
					<%
				}
			%>
		</div>
		</div>

		<!-- End of User Login -->


		<!-- Start of Latest News -->

		<div class="box_container">
		<div id="news">
		<center><img src="images/news_title.gif"></img></center>
		<hr><br>
	<jsp:include page="newsP.jsp"/>
		<div id="nn"></div>
			<div class="clearthis">&nbsp;</div>
		</div>
		</div>

		<!-- End of Latest News -->


	</div>

	<!-- End of Left Sidebar -->


	<!-- Start of Main Content Area -->

	<div id="maincontent_container">
	<div id="maincontent">


		<!--div id="maincontent_top"-->

			<!-- Start of How We Started -->
			<table border="0"  width="100%">
			<tr>
				<td width="30%"><center>Accepted</center></td><td width="30%"><center>Pended</center></td><td width="30%"><center>Rejected</center></td>
			</tr>
			</table>
			<DIV id=Demo4 width="100%">
				<DIV class=DragContainer id=DragContainer4 overClass="OverDragContainer">
				<%
				for(int i=0;i<id.length;i++)
				{
					if(status[i].equals("accepted"))
					{
						if(!type[i].equals("root"))
						{
					%>
					<DIV class=DragBox id="<%=id[i]%>" overClass="OverDragBox" dragClass="DragDragBox"><%=usernames[i]+"<br/>"+type[i]%></DIV>
					<%
						}
					}
				}
					%>
				</DIV>
				<DIV class=DragContainer id=DragContainer5 overClass="OverDragContainer">
				<%
				for(int i=0;i<id.length;i++)
				{
					if(status[i].equals("pend"))
					{
						if(!type[i].equals("root"))
						{
					%>
					<DIV class=DragBox id="<%=id[i]%>" overClass="OverDragBox" dragClass="DragDragBox"><%=usernames[i]+"<br/>"+type[i]%></DIV>
					<%
						}
					}
				}
				%>
				</DIV>
				<DIV class=DragContainer id=DragContainer6 overClass="OverDragContainer">
				<%
				for(int i=0;i<id.length;i++)
				{
					if(status[i].equals("drop"))
					{
						if(!type[i].equals("root"))
						{
					%>
					<DIV class=DragBox id="<%=id[i]%>" overClass="OverDragBox" dragClass="DragDragBox"><%=usernames[i]+"<br/>"+type[i]%></DIV>
					<%
						}
					}
				}
				%>
				</DIV>
			</DIV>
			
			<div id="started_container">
			<div id="started">
			
				

<p></p>
				
				<p></p>
				
				<p></p>
				<p></p>

			</div>
			</div>
			<div id="right_container">
			
			</div>
		<!--/div-->
	</div>
	</div>
	<div>
			<form name="controlProject" method="GET" action="changeUserStatus.jsp" onsubmit="return check()">
			<%
			for(int i=0;i<id.length;i++)
			{
				if(!type[i].equals("root"))
				{
				%>
				<input type="hidden" id="in<%=i%>" name="<%=id[i]%>" value="<%=status[i]%>" />
				<%
				}
			}
			%>
			<input type="submit" value="Save status" />
			</form>
			</div>
	<div id="page_footer">
	Style powered by <a href="http://www.freewebsitetemplates.com/">Free Website Templates</a>
	</div>
	<div class="clearthis">&nbsp;</div>
</div>
</body>
</html>
<%
} else {
	response.sendRedirect("error.jsp");
}
%>